<?php

namespace app\admin\controller;

use think\Controller;
use think\Db;

class Document extends Controller
{
    private $categories = array();
    private $links = array();
    private $person = array();
    private $relatedFigures = array();
    private $organization = array();
    /**
     * 格式化日期
     * @param string $date 日期字符串
     * @return string|null 格式化后的日期或null
     */
    private function formatDate($date)
    {
        if (empty($date) || $date == '0000-00-00' || $date == '0000-00-00 00:00:00') {
            return null;
        }
        return date('Y-m-d', strtotime($date));
    }

    public function getDocument()
    {
        $data = request()->put();

        if (empty($data['dh'])) {
            return json(array(
                'code' => 404,
                'message' => '档号不能为空'
            ));
        }


        $dh = $data['dh'];
        // $qzh = $data['qzh'];

        $map = array();
        if (!empty($dh)) {
            $map['dh'] = array('=', $dh);
        }

        // if(!empty($qzh)){
        //     $map['qzh'] = array('=', $qzh);
        // }

        $result = Db::table('zstp_article')
            ->where($map)
            ->find();

            

        if (empty($result)) {
            return json(array(
                'code' => 400,
                'message' => '档号不存在'
            ));
        }

        $articleId = $result['id'];


        //
        $personInfo = array(
            "id" => 2,
            "name" => "著录信息",
            "type" => "person",
            "color" => "#fac455",
            "symbol" => "grxx",
        );

        $this->person[] = $personInfo;

        $categories = array(
            "name" => "著录信息",
        );

        $this->categories[] = $categories;

        $links = array(
            "category" => $categories['name'],
            "source" => 1,
            "target" => 2,
        );

        $this->links[] = $links;

        // 获取档号信息
        $this->getZlxxInfo($result);

        //同年同宗同责任者的文档
         
        $mapQ["zrz"]=array("=",  $result['zrz']);

        $mapQ["qzh"]=array("=",  $result['qzh']);

        $mapQ["lbh"]=array("=",  $result['lbh']);

        $articleList = Db::table('zstp_article')
            ->where($mapQ)
            ->limit(50)
            ->field('id, dh ,tm')
            ->select();

      
        $this->listArticle($articleList);
            
        
        //相关人物
        $relatedFigures = array();


        //人物表
        $map_personal_attributes = array();
        $map_personal_attributes['article_id'] = array('=', $articleId);
        $map_personal_attributes['is_delete'] = array('=', '0');
        $personal_attributes = Db::table('zstp_neo4j_personal_attributes')
            ->field('id, name')
            ->where($map_personal_attributes)
            ->select();

        foreach ($personal_attributes as $value) {
            $this->relatedFigures[] = $value['name'];
        }

        //相关人物
        $this->xgrw( $personal_attributes );


        //相关机构
        $map_organization = array();
        $map_organization['article_id'] = array('=', $articleId);
        $map_organization['is_delete'] = array('=', '0');
        $organization = Db::table('zstp_neo4j_organization')
            ->field('id, unit_name')
            ->where($map_organization)
            ->select();

        

        foreach ($organization as $value) {
            $this->organization[] = $value['unit_name'];
        }

        $this->xgjg( $organization );


        $eventArray = array();
        //相关事件


        //出国事件
        $map_abroad_event = array();
        $map_abroad_event['article_id'] = array('=', $articleId);
        $map_abroad_event['is_delete'] = array('=', '0');
        // if (!empty($qzh)) {
        //     $map_abroad_event['qzh'] = array('=', $qzh);
        // }
        $abroad_events = Db::table('zstp_neo4j_abroad_event')
            ->where($map_abroad_event)
            ->field('event_type,country, personnel_name')
            ->select();
        foreach ($abroad_events as $value) {
            $eventArray []= array(
                "type" => "cgsj",
                "title" =>  "{$value['personnel_name']}  {$value['event_type']} "
            );
        }

        
        // 任职免职事件
        $map_position_event = array();
        $map_position_event['article_id'] = array('=', $articleId);
        $map_position_event['is_delete'] = array('=', '0');
        // if (!empty($qzh)) {
        //     $map_position_event['qzh'] = array('=', $qzh);
        // }
        $position_events = Db::table('zstp_neo4j_position_event')
            ->where($map_position_event)
            ->field('event_type,personnel_name,current_position ,original_position')
            ->select();

        foreach ($position_events as $value) {

            $title = "{$value['personnel_name']}  {$value['event_type']} ";
            if (!empty($value['current_position'])) {
                $title .= " {$value['current_position']} ";
            }else{
                $title .= " {$value['original_position']} ";
            }

        
            $eventArray[] = array(
                "type" => "rzsj",
                "title" =>$title
            );
        }





        // 晋升事件
        $map_rank_event = array();
        $map_rank_event['article_id'] = array('=', $articleId);
        $map_rank_event['is_delete'] = array('=', '0');
        // if (!empty($qzh)) {
        //     $map_rank_event['qzh'] = array('=', $qzh);
        // }
        $rank_events = Db::table('zstp_neo4j_rank_event')
            ->field('event_type,personnel_name,summary')
            ->where($map_rank_event)
            ->select();

        foreach ($rank_events as $value) {
            $eventArray[] = array(
                "type" => "jssj",
                "title" => "{$value['personnel_name']}  {$value['event_type']}  {$value['summary']}"
            );
        }


        // 奖惩事件
        $map_reward_event = array();
        $map_reward_event['article_id'] = array('=', $articleId);
        $map_reward_event['is_delete'] = array('=', '0');
        // if (!empty($qzh)) {
        //     $map_reward_event['qzh'] = array('=', $qzh);
        // }
        $reward_events = Db::table('zstp_neo4j_rewards_punishments_event')
            ->field('event_type,subject_name,summary')
            ->where($map_reward_event)
            ->select();

        foreach ($reward_events as $value) {
            $eventArray[] = array(
                "type" => "jcsj",
                "title" => "{$value['subject_name']}  {$value['event_type']}  {$value['summary']}"
            );
        }


        $this->xgsj($eventArray );




        // 中心人物
        $personCenter = array(
            "id" => 1,
            "name" => $dh,
            "type" => "person",
            "color" => "#fac455",
            "symbol" => "zhongxin",
        );

        $this->person[] = $personCenter;


        $this->categories = array_unique_by_field($this->categories, 'name');


        $neo4jData = array(
            "categories" => $this->categories,
            "links" => $this->links,
            "person" => $this->person,
        );


        

        return json(array(
            'code' => 200,
            'data' => array(
                "person" => $result, 
                "events" => $eventArray, 
                "neo4jData" => $neo4jData,
                "xgrwlist" => $this->relatedFigures,
                "xgsjlist" => $this->organization,
                "qzh" => $result['qzh'],
          
             
              

            ),
            'message' => 'success'
        ));
    }

    public function xgsj($eventArray){
        if (empty($eventArray)) {
            return;
        }


        $relationInfo = array(
            "id" => 30000,
            "name" => "相关事件",
            "type" => "person",
            "color" => "#fac455",
            "symbol" => "jspj",
        );

        $this->person[] = $relationInfo;

        $categories = array(
            "name" => "相关事件",
        );

        $this->categories[] = $categories;

        $links = array(
            "category" => "相关事件",
            "source" => 1,
            "target" => 30000,
        );

        $this->links[] = $links;

        foreach ($eventArray as $key => $value) {
            $id = "xgsj_" . $key; 
            $relationInfo = array(
                "id" => $id,
                "name" => $value['title'],
                "type" => "person",
                "color" => "#fac455",
                "symbol" => "circle",
            );
            $this->person[] = $relationInfo;
            $categories = array(
                "name" => "相关事件",
            );
            $this->categories[] = $categories;

            $links = array(
                "category" => "相关事件",
                "source" => 30000,
                "target" => $id,
            );
            $this->links[] = $links;
        }
        
      
    }


    public function xgjg( $organization ){

        if (empty($organization)) {
            return;
        }

        $relationInfo = array(
            "id" => 20000,
            "name" => "相关机构",
            "type" => "person",
            "color" => "#fac455",
            "symbol" => "shgx",
        );

        $this->person[] = $relationInfo;

        $categories = array(
            "name" => "相关机构",
        );

        $this->categories[] = $categories;

        $links = array(
            "category" => "相关机构",
            "source" => 1,
            "target" => 20000,
        );

        $this->links[] = $links;


        foreach ($organization as $key => $value) {
            $id = "xgjg_" . $value["id"];
            $relationInfo = array(
                "id" => $id,
                "name" => $value['unit_name'],
                "type" => "person",
                "color" => "#fac455",
                "symbol" => "circle",
            );
            $this->person[] = $relationInfo;
            $categories = array(
                "name" => "相关机构",
            );
            $this->categories[] = $categories;

            $links = array(
                "category" => "相关机构",
                "source" => 20000,
                "target" => $id,
            );
            $this->links[] = $links;
        }
        
        
        
    }


    public function xgrw( $personal_attributes ){

        if (empty($personal_attributes)) {
            return;
        }

        $relationInfo = array(
            "id" => 10000,
            "name" => "相关人物",
            "type" => "person",
            "color" => "#fac455",
            "symbol" => "shgx",
        );

        $this->person[] = $relationInfo;

        $categories = array(
            "name" => "相关人物",
        );

        $this->categories[] = $categories;

        $links = array(
            "category" => "相关人物",
            "source" => 1,
            "target" => 10000,
        );

        $this->links[] = $links;

        foreach ($personal_attributes as $key => $value) {
            $id = "xgrw_" . $value["id"];
            $relationInfo = array(
                "id" => $id,
                "name" => $value['name'],
                "type" => "renwu",
                "color" => "#1296db",
                "symbol" => "circle",
            );
            $this->person[] = $relationInfo;
            $categories = array(
                "name" => "相关人物",
            );
            $this->categories[] = $categories;

            $links = array(
                "category" => "相关人物",   
                "source" => 10000,
                "target" => $id,
            );
            $this->links[] = $links;
        }
                
        

        
        
    }


    // 人物社会关系
    public function personSocialRelations($social_relations)
    {


        if (empty($social_relations)) {
            return;
        }

        $relationInfo = array(
            "id" => 1000,
            "name" => "社会关系",
            "type" => "person",
            "color" => "#fac455",
            "symbol" => "shgx",
        );
        $this->person[] = $relationInfo;
        $categories = array(
            "name" => "社会关系",
        );
        $this->categories[] = $categories;

        $links = array(
            "category" => "社会关系",
            "source" => 1,
            "target" => 1000,
        );
        $this->links[] = $links;

        foreach ($social_relations as $key => $value) {
            $id = "shgx_" . $value["id"];
            $relationInfo = array(
                "id" => $id,
                "name" => $value['name'],
                "type" => "person",
                "color" => "#1296db",
                "symbol" => "circle",
            );
            $this->person[] = $relationInfo;
            $categories = array(
                "name" => $value['relationship_type'],
            );
            $this->categories[] = $categories;

            $links = array(
                "category" => $value['relationship_type'],
                "source" => 1000,
                "target" => $id,
            );
            $this->links[] = $links;

            $this->articleIdArr[] = $value['article_id'];
        }
    }

    // 职位事件
    public function personPositionEvents($position_events)
    {
        if (empty($position_events)) {
            return;
        }

        $positionInfo = array(
            "id" => 2000,
            "name" => "职位变动",
            "type" => "person",
            "color" => "#fac455",
            "symbol" => "zwbd",
        );
        $this->person[] = $positionInfo;
        $categories = array(
            "name" => "职位变动",
        );
        $this->categories[] = $categories;

        $links = array(
            "category" => "职位变动",
            "source" => 1,
            "target" => 2000,
        );
        $this->links[] = $links;

        foreach ($position_events as $key => $value) {
            $id = "zwbd_" . $value["id"];
            $positionInfo = array(
                "id" => $id,
                "name" => $value['current_position'] ?: $value['original_position'],
                "type" => "person",
                "color" => "#f26667",
                "symbol" => "circle",
            );
            $this->person[] = $positionInfo;
            $categories = array(
                "name" => $value['event_type'],
            );
            $this->categories[] = $categories;

            $links = array(
                "category" => $value['event_type'],
                "source" => 2000,
                "target" => $id,
            );
            $this->links[] = $links;
        }
    }

    // 晋升事件
    public function personRankEvents($rank_events)
    {
        if (empty($rank_events)) {
            return;
        }

        $rankInfo = array(
            "id" => 3000,
            "name" => "晋升情况",
            "type" => "person",
            "color" => "#fac455",
            "symbol" => "jspj",
        );
        $this->person[] = $rankInfo;
        $categories = array(
            "name" => "晋升情况",
        );
        $this->categories[] = $categories;

        $links = array(
            "category" => "晋升情况",
            "source" => 1,
            "target" => 3000,
        );
        $this->links[] = $links;

        foreach ($rank_events as $key => $value) {
            $id = "jspj_" . $value["id"];
            $rankInfo = array(
                "id" => $id,
                "name" => $value['summary'],
                "type" => "person",
                "color" => "#46a6ff",
                "symbol" => "circle",
            );
            $this->person[] = $rankInfo;
            $categories = array(
                "name" => $value['event_type'],
            );
            $this->categories[] = $categories;

            $links = array(
                "category" => $value['event_type'],
                "source" => 3000,
                "target" => $id,
            );
            $this->links[] = $links;
        }
    }

    // 出国事件
    public function personAbroadEvents($abroad_events)
    {
        if (empty($abroad_events)) {
            return;
        }

        $abroadInfo = array(
            "id" => 4000,
            "name" => "出国情况",
            "type" => "person",
            "color" => "#green",
            "symbol" => "cgsj",
        );
        $this->person[] = $abroadInfo;
        $categories = array(
            "name" => "出国情况",
        );
        $this->categories[] = $categories;

        $links = array(
            "category" => "出国情况",
            "source" => 1,
            "target" => 4000,
        );
        $this->links[] = $links;

        foreach ($abroad_events as $key => $value) {
            $id = "cgsj_" . $value["id"];
            $abroadInfo = array(
                "id" => $id,
                "name" => $value['country'],
                "type" => "person",
                "color" => "#fac455",
                "symbol" => "circle",
            );
            $this->person[] = $abroadInfo;
            $categories = array(
                "name" => $value['event_type'],
            );
            $this->categories[] = $categories;

            $links = array(
                "category" => $value['event_type'],
                "source" => 4000,
                "target" => $id,
            );
            $this->links[] = $links;
        }
    }

    // 奖惩事件
    public function personRewardEvents($reward_events)
    {
        if (empty($reward_events)) {
            return;
        }

        $rewardInfo = array(
            "id" => 5000,
            "name" => "奖惩情况",
            "type" => "person",
            "color" => "#fac455",
            "symbol" => "jcsj",
        );
        $this->person[] = $rewardInfo;
        $categories = array(
            "name" => "奖惩情况",
        );
        $this->categories[] = $categories;

        $links = array(
            "category" => "奖惩情况",
            "source" => 1,
            "target" => 5000,
        );
        $this->links[] = $links;

        foreach ($reward_events as $key => $value) {
            $id = "jcsj_" . $value["id"];
            $rewardInfo = array(
                "id" => $id,
                "name" => $value['summary'],
                "type" => "person",
                "color" => "#1296db",
                "symbol" => "circle",
            );
            $this->person[] = $rewardInfo;
            $categories = array(
                "name" => $value['event_type'],
            );
            $this->categories[] = $categories;

            $links = array(
                "category" => $value['event_type'],
                "source" => 5000,
                "target" => $id,
            );
            $this->links[] = $links;
        }
    }

    // 相关档案
    public function listArticle($articleList)
    {
        if (empty($articleList)) {
            return;
        }

        $articleInfo = array(
            "id" => 6000,
            "name" => "相关档案",
            "type" => "person",
            "color" => "#fac455",
            "symbol" => "xgda",
        );
        $this->person[] = $articleInfo;
        $categories = array(
            "name" => "相关档案",
        );
        $this->categories[] = $categories;

        $links = array(
            "category" => "相关档案",
            "source" => 1,
            "target" => 6000,
        );
        $this->links[] = $links;

        foreach ($articleList as $key => $value) {
            $id = "xgda_" . $value["id"];
            $articleInfo = array(
                "dh" => $value['dh'],
                "id" => $id,
                "name" => $value['tm'],
                "type" => "document",
                "color" => "#9fd1d8",
                "symbol" => "circle",
            );
            $this->person[] = $articleInfo;
            $categories = array(
                "name" => "档案",
            );
            $this->categories[] = $categories;

            $links = array(
                "category" => "档案",
                "source" => 6000,
                "target" => $id,
            );
            $this->links[] = $links;
        }
    }
        // 获取文档信息
        function getZlxxInfo($personData)
        {
    
            if (!empty($personData['tm'])) {
                $personInfo = array(
                    "id" => 3,
                    "name" => $personData['tm'],
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "题名",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "题名",
                    "source" => 2,
                    "target" => 3,
                );
                $this->links[] = $links;
            }
    
            if (!empty($personData['dh'])) {
                $personInfo = array(
                    "id" => 4,
                    "name" => $personData['dh'],
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "档号",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "档号",
                    "source" => 2,
                    "target" => 4,
                );
                $this->links[] = $links;
            }
    
            if (!empty($personData['ztc'])) {
                $personInfo = array(
                    "id" => 5,
                    "name" => $personData['ztc'],
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "主题词",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "主题词",
                    "source" => 2,
                    "target" => 5,
                );
                $this->links[] = $links;
            }
    
            if (!empty($personData['mj'])) {
                $personInfo = array(
                    "id" => 6,
                    "name" => $personData['mj'],
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "密级",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "密级",
                    "source" => 2,
                    "target" => 6,
                );
                $this->links[] = $links;
            }
    
            //保管期限
    
            if (!empty($personData['bgqx'])) {
                $personInfo = array(
                    "id" => 7,
                    "name" => $personData['bgqx'],
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "保管期限",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "保管期限",
                    "source" => 2,
                    "target" => 7,
                );
                $this->links[] = $links;
            }
    
            // 分类号  
    
            if (!empty($personData['flh'])) {
                $personInfo = array(
                    "id" => 8,
                    "name" => $personData['flh'],
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "分类号",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "分类号",
                    "source" => 2,
                    "target" => 8,
                );
                $this->links[] = $links;
            }
    
            //案卷号
            if (!empty($personData['ajh'])) {
                $personInfo = array(
                    "id" => 9,
                    "name" => $personData['ajh'],
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "案卷号",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "案卷号",
                    "source" => 2,
                    "target" => 9,
                );
                $this->links[] = $links;
            }
    
            //件号
    
            if (!empty($personData['jh'])) {
                $personInfo = array(
                    "id" => 10,
                    "name" => $personData['jh'],
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "件号",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "件号",
                    "source" => 2,
                    "target" => 10,
                );
                $this->links[] = $links;
            }
    
            // 关键词
    
            if (!empty($personData['gjc'])) {
                $personInfo = array(
                    "id" => 11,
                    "name" => $personData['gjc'],
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "关键词",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "关键词",
                    "source" => 2,
                    "target" => 11,
                );
                $this->links[] = $links;
            }
    
            // 类别号
    
            if (!empty($personData['lbh'])) {
                $personInfo = array(
                    "id" => 12,
                    "name" => $personData['lbh'],
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "类别号",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "类别号",
                    "source" => 2,
                    "target" => 12,
                );
                $this->links[] = $links;
            }
    
            //文种
    
            if (!empty($personData['wz'])) {
                $personInfo = array(
                    "id" => 13,
                    "name" => $personData['wz'],
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "文种",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "文种",
                    "source" => 2,
                    "target" => 13,
                );
                $this->links[] = $links;
            }
    
            //时间
    
            if (!empty($personData['sj'])) {
                $personInfo = array(
                    "id" => 14,
                    "name" => $personData['sj'],
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "时间",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "时间",
                    "source" => 2,
                    "target" => 14,
                );
                $this->links[] = $links;
            }
    
            //文件编号
    
            if (!empty($personData['wjbh'])) {
                $personInfo = array(
                    "id" => 15,
                    "name" => $personData['wjbh']." ",
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "文件编号",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "文件编号",
                    "source" => 2,
                    "target" => 15,
                );
                $this->links[] = $links;
            }
    
            //载体类型
    
            if (!empty($personData['ztlx'])) {
                $personInfo = array(
                    "id" => 16,
                    "name" => $personData['ztlx'],
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "载体类型",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "载体类型",
                    "source" => 2,
                    "target" => 16,
                );
                $this->links[] = $links;
            }
    
            // 载体数量
    
            if (!empty($personData['ztsl'])) {
    
                //  $personData['ztsl'] 转成 字符串
                $personInfo = array(
                    "id" => 17,
                    "name" => $personData['ztsl']." ",
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "载体数量",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "载体数量",
                    "source" => 2,
                    "target" => 17,
                );
                $this->links[] = $links;
            }
    
            // 载体单位
            if (!empty($personData['ztdw'])) {
                $personInfo = array(
                    "id" => 18,
                    "name" => $personData['ztdw'],
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "载体单位",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "载体单位",
                    "source" => 2,
                    "target" => 18,
                );
                $this->links[] = $links;
            }
    
            // 载体规格
            if (!empty($personData['ztzg'])) {
                $personInfo = array(
                    "id" => 19,
                    "name" => $personData['ztzg'],
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "载体规格",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "载体规格",
                    "source" => 2,
                    "target" => 19,
                );
                $this->links[] = $links;
            }
    
            //责任者
            if (!empty($personData['zrz'])) {
                $personInfo = array(
                    "id" => 20,
                    "name" => $personData['zrz'],
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "责任者",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "责任者",
                    "source" => 2,
                    "target" => 20,
                );
                $this->links[] = $links;
            }
    
            //缩微号
            if (!empty($personData['swh'])) {
                $personInfo = array(
                    "id" => 21,
                    "name" => $personData['swh'],
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "缩微号",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "缩微号",
                    "source" => 2,
                    "target" => 21,
                );
                $this->links[] = $links;
            }
    
            //档案管号
            if (!empty($personData['dagdh'])) {
                $personInfo = array(
                    "id" => 22,
                    "name" => $personData['dagdh'],
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "档案管号",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "档案管号",
                    "source" => 2,
                    "target" => 22,
                );
                $this->links[] = $links;
            }
            
            // 数据类型
            if (!empty($personData['sjls'])) {
                $personInfo = array(
                    "id" => 23,
                    "name" => $personData['sjls'],
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "数据类型",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "数据类型",
                    "source" => 2,
                    "target" => 23,
                );
                $this->links[] = $links;
            }
    
            //附注
            if (!empty($personData['fz'])) {
                $personInfo = array(
                    "id" => 24,
                    "name" => $personData['fz'],
                    "type" => "person",
                    "color" => "#fac455",
                    "symbol" => "circle",
                );
                $this->person[] = $personInfo;
                $categories = array(
                    "name" => "附注",
                );
                $this->categories[] = $categories;
                $links = array(
                    "category" => "附注",
                    "source" => 2,
                    "target" => 24,
                );
                $this->links[] = $links;
            }
            
            
    
    
    
        }
}
